package com.gxa.retail_admin.controller;

import com.gxa.common.vo.JsonResult;
import com.gxa.modules.pojo.Account;
import com.gxa.modules.service.AccountService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;



@Controller
@Api(value = "测试数据",tags = "挂账列表接口—陈峰江")
public class AccountController {
    @Autowired(required = false)
    private AccountService accountService;

    /**
     * 挂账查询
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("/queryAccount")
    @ApiOperation(value = "运营会员挂账查询",notes = "运营会员挂账查询",httpMethod = "GET",response = JsonResult.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功"),
            @ApiResponse(code = 400,message = "参数接口问题"),
            @ApiResponse(code = 405,message = "方法不允许"),
            @ApiResponse(code = 500,message = "后端问题"),
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "limit",value = "每页显示条数",paramType = "query",dataType = "String")
    })
    @ResponseBody
    @RequiresPermissions("挂账列表")
    public JsonResult queryAccount(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit) {

        return accountService.queryAccount(page,limit);
    }

    /**
     * 订单号搜索
     * @param account_number
     * @return
     */
    @GetMapping(value = "/searchAccount")
    @ApiOperation(value = "挂账单号搜索",notes = "按挂账订单号搜索",httpMethod = "GET", response = JsonResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "account_number",value = "挂账单号搜索",paramType = "query",required = false,dataType ="String" )
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "success"),
            @ApiResponse(code=404,message = "找不到页面，接口或参数错误"),
            @ApiResponse(code = 405,message = "方法不允许"),
            @ApiResponse(code=500,message = "后台错误"),
    })
    @ResponseBody
    @RequiresPermissions("挂账列表")
    public JsonResult searchAccount(Integer account_number){

        return accountService.searchAccount(account_number);
    }

    /**
     * 查询今日新增
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/queryTodayAccount")
    @ApiOperation(value = "今日新增接口",notes = "查询今日新增订单",httpMethod = "GET", response = JsonResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "String",required = false),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "success"),
            @ApiResponse(code=404,message = "找不到页面，接口或参数错误"),
            @ApiResponse(code=405,message = "方法不允许"),
            @ApiResponse(code=500,message = "后台错误"),
    })
    @ResponseBody
    @RequiresPermissions("挂账列表")
    public JsonResult queryTodayAccount(@RequestParam(defaultValue = "1")Integer currentPage,@RequestParam(defaultValue = "10")Integer pageSize) {

        return accountService.queryTodayAccount(currentPage,pageSize);

    }
    /**
     * 查询昨日新增
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/queryYesterdayAccount")
    @ApiOperation(value = "昨日新增接口",notes = "查询昨日新增订单",httpMethod = "GET", response = JsonResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "String",required = false),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "success"),
            @ApiResponse(code=404,message = "找不到页面，接口或参数错误"),
            @ApiResponse(code=405,message = "方法不允许"),
            @ApiResponse(code=500,message = "后台错误"),
    })
    @ResponseBody
    @RequiresPermissions("挂账列表")
    public JsonResult queryYesterdayAccount(@RequestParam(defaultValue = "1")Integer currentPage,@RequestParam(defaultValue = "10")Integer pageSize) {


        return accountService.queryYesterdayAccount(currentPage,pageSize);

    }

    /**
     * 查询本周
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/queryWeekAccount")
    @ApiOperation(value = "本周新增接口",notes = "查询本周新增订单",httpMethod = "GET", response = JsonResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "String",required = false),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "success"),
            @ApiResponse(code=404,message = "找不到页面，接口或参数错误"),
            @ApiResponse(code=405,message = "方法不允许"),
            @ApiResponse(code=500,message = "后台错误"),
    })
    @ResponseBody
    @RequiresPermissions("挂账列表")
    public JsonResult queryWeekAccount(@RequestParam(defaultValue = "1")Integer currentPage,@RequestParam(defaultValue = "10")Integer pageSize){


        return accountService.queryWeekAccount(currentPage,pageSize);
    }

    /**
     * 查询本月新增
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/queryMonthAccount")
    @ApiOperation(value = "本月新增接口",notes = "查询本月新增订单",httpMethod = "GET", response = JsonResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "String",required = false),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "success"),
            @ApiResponse(code=404,message = "找不到页面，接口或参数错误"),
            @ApiResponse(code=405,message = "方法不允许"),
            @ApiResponse(code=500,message = "后台错误"),
    })
    @ResponseBody
    @RequiresPermissions("挂账列表")
    public JsonResult queryMonthAccount(@RequestParam(defaultValue = "1")Integer currentPage,@RequestParam(defaultValue = "10")Integer pageSize){


        return  accountService.queryMonthAccount(currentPage,pageSize);
    }

    /**
     * 时间段查询订单
     * @param beforeTime
     * @param afterTime
     * @return
     */
    @GetMapping(value = "/queryBetweenTimeAccount")
    @ApiOperation(value = "范围时间查询",notes = "查询范围时间订单",httpMethod = "GET", response = JsonResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "beforeTime",value = "前一个时间",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "afterTime",value = "后一个时间",paramType = "query",dataType = "String",required = false),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "success"),
            @ApiResponse(code=404,message = "找不到页面，接口或参数错误"),
            @ApiResponse(code=405,message = "方法不允许"),
            @ApiResponse(code=500,message = "后台错误"),
    })
    @ResponseBody
    @RequiresPermissions("挂账列表")
    public JsonResult queryBetweenTimeAccount(@RequestParam(defaultValue = "1")Integer currentPage,@RequestParam(defaultValue = "10")Integer pageSize,String beforeTime,String afterTime){


        return accountService.queryBetweenTimeAccount(currentPage,pageSize,beforeTime,afterTime);
    }
}
